package de.koller.aframe.gl.obj;

import de.koller.oceanFramework.math.RVec3;
import org.lwjgl.opengl.GL11;

abstract public class RenderPrimitiv {
	
	public final float[] verteces;
	public final float[] uv;
	protected final int glType;
	
	public RenderPrimitiv( int glType, int verteces ) {
		this.verteces = new float[ verteces*3 ];
		this.uv = new float[ verteces*2 ];
		this.glType = glType;
	}
	
	public void update( RVec3... v ) {
		for( int i = 0; i < v.length; i++ ) {
			verteces[(i*3)]	  = v[i].x;
			verteces[(i*3)+1] = v[i].y;
			verteces[(i*3)+2] = v[i].z;
		}
	}

	public void renderStructure() {
		renderStructure( verteces );
	}
	
	public void renderStructure( float... v ) {
		GL11.glBegin( glType );
		
		for( int i = 0, j = 0; i < verteces.length; i += 3, j += 2 ) {
			GL11.glTexCoord2f( uv[j], uv[j+1] );
			GL11.glVertex3f( v[i], v[i+1], v[i+2] );
		}
			
		GL11.glEnd();
	}
	
}
